function reduce(arr,callback,initData=[]){
    arr.forEach(function(item,i){
        initData = callback.call(item,initData,item,i)
    })
    return initData;
}

/** 
 *  
    var obj = {school:{name:"国防",id:007},age:18}
    reduce('school.name'.split('.'),function(data,item){
        return data[item]
    },obj) 
 */